#include <STC15F2K60S2.H>
#include <intrins.h>

void Timer0Init(void)	;
void led_dispaly();
void Delay1ms(unsigned char n);

unsigned char dspcom;	
unsigned char time=50;
	
void main()
{
	while(1)
	{
		led_dispaly();
	}
}

void Timer0Init(void)		//1微秒@12.000MHz
{
	AUXR &= 0x7F;		//定时器时钟12T模式
	TMOD &= 0xF0;		//设置定时器模式
	TL0 = 0x18;		//设置定时初值
	TH0 = 0xFc;		//设置定时初值
	TF0 = 0;		//清除TF0标志
	ET0 = 1;
	EA = 1;
	TR0 = 1;		//定时器0开始计时
}

void time_0_irs() interrupt 1
{
	led_dispaly();
}

void Delay1ms(unsigned char n)		//@12.000MHz
{
	unsigned char i, j;
    do
		{
	i = 12;
	j = 169;
	do
	{
		while (--j);
	} while (--i);
    }while(n--);
}


void led_dispaly()
{
	unsigned char ucled;
	ucled = 0xfe;
	//消影
//	P2 = ((P2&0x1f)|0x4f);
//	P0 = 0xff;
//	P2 = 0x1f;

	P2 = ((P2&0x1f)|0x8f);
	ucled = _crol_(ucled,1);
	P0 = ucled;
	Delay1ms(time);
	P2 = 0x1f;
	time=time-10;
	
	
}





//关闭外设
/*void cls_buzz(void)
{
	P2 = (P2&0x1F|0xA0);
	P0 = 0x00;
	P2 &= 0x1F;
}

//延时函数
void delay(void)
{
	unsigned char i, j, k;

	_nop_();
	_nop_();
	i = 9;
	j = 104;
	k = 139;
	do
	{
		do
		{
			while (--k);
		} while (--j);
	} while (--i);
}

//主函数
void main(void)
{
    unsigned char i;
	
	cls_buzz();
    
    while(1)
    {
		for(i=0; i<8; i++)
		{
			P2 = ((P2&0x1f)|0x80);
			P0 = ~(0x01<<i);  //左移i位，按位取反
			P2 &= 0x1f;
			delay();
		}
    }
}
*/








